home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / write.c < prev   
Encoding:
C/C++ Source or Header  |  1989-12-28  |  774 b   |  40 lines

  1. #include "lib.h"
  2.  
  3. #ifndef __MSHORT__
  4. asm(".text; .even; .globl _write; _write:"); /* dept of dirty tricks */
  5. #endif
  6. PUBLIC long lwrite(fd, buffer, nbytes)
  7. int fd;
  8. _CONST _VOIDSTAR buffer;
  9. long nbytes;
  10. {
  11.   long tot, left;
  12.   int n;
  13.  
  14.   if(nbytes <= 32767)
  15.   {
  16.       return (long)callm1(FS, WRITE, fd, (int)nbytes, 0, buffer, NIL_PTR, NIL_PTR);
  17.   }
  18.   for( tot = 0, left = nbytes; left > 0; )
  19.   {
  20.     n = (left > 32767) ? 32767 : (int)left;
  21.     if((n = callm1(FS, WRITE, fd, n, 0, buffer, NIL_PTR, NIL_PTR)) < 0)
  22.         return((long)n);
  23.     if(n == 0) return(tot);
  24.     tot += n;
  25.     left -= n;
  26.     (char *)buffer += n;
  27.   }
  28.   return(tot);
  29. }
  30.  
  31. #ifdef __MSHORT__
  32. PUBLIC int write(fd, buffer, nbytes)
  33. int fd;
  34. _CONST _VOIDSTAR buffer;
  35. int nbytes;
  36. {
  37.     return (int)lwrite(fd, buffer, (long)nbytes);
  38. }
  39. #endif
  40.